<?php

class Template {
    
    var $template;
    
    function Template($template) 
    {
	global $options;
	$this->options = $options;
	$this->template = $template;
	return true;
    }
    
    function run($item,$run=true) 
    {
	if(!is_array($item)) return false;
	
	$data = file("html_templates/".$this->template.".php");
	$data = join($data,"\n");	
	
	foreach(array_keys($item) as $k) 
	{
	    if(!is_int($k))
	      $data = str_replace("<!$k>",addslashes($item[$k]),$data);
	}         
	
	if($run == true) 
	{
	    ob_start();
	    eval("?>$data<?");
	    $data = ob_get_contents();
	    ob_end_clean();
	    print(stripslashes($data));
	    return true;
	} 
	else
	  return $data;
    }
    
}

?>
